<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<html>
<head>
  <title>职位管理</title>
</head>

<body>
  <c:if test="${not empty message}">
    <div id="message" class="alert alert-success"><button data-dismiss="alert" class="close">×</button>${message}</div>
  </c:if>
  <div class="row">
    <div class="span4 offset7">
      <form class="form-search" action="#">
        <label>名称：</label> <input type="text" name="search_LIKE_name" class="input-medium" value="${param.search_LIKE_name}"> 
        <button type="submit" class="btn" id="search_btn">Search</button>
      </form>
    </div>
    <tags:sort/>
  </div>

  <c:forEach items="${positions.content}" var="position">
  <table valign="middle" class="table table-bordered table-condensed">
    <tr>
      <td width="10%"><strong>名称</strong></td>
      <td width="20%"><a href="${ctx}/hr/position/update/${position.id}">${position.name}</a></td>
      <td width="9%"><strong>公司 / 部门</strong></td>
      <td width="46%" colspan="5">
        ${position.company.name}
        <c:if test="${not empty position.department}"> / ${position.department.name}</c:if>
      </td>
      <td width="15%" rowspan="2" style="vertical-align: middle">
        <c:choose>
          <c:when test="${closeDate < nowDate}"><a href="${ctx}/hr/position/refresh/${position.id}">刷新</a></c:when>
          <c:otherwise>已刷新</c:otherwise>
        </c:choose>
        <a href="${ctx}/hr/position/copy/${position.id}">再发布</a>
        <c:choose>
        <c:when test="${position.status == 0}">
          <a href="${ctx}/hr/position/disable/${position.id}">暂停</a>
        </c:when>
        <c:otherwise>
          <a href="${ctx}/hr/position/enable/${position.id}">启用</a>
        </c:otherwise>
        </c:choose>
        <a href="${ctx}/hr/position/delete/${position.id}">过滤</a>
        <a href="${ctx}/hr/position/${position.id}/cv">看简历</a>
        <a href="${ctx}/hr/position/${position.id}/history">历史</a>
      </td>
    </tr>
    <tr>
      <td><strong>工作地点</strong></td>
      <td>
        <c:forEach items="${provinces}" var="province">
          <c:if test="${province.id == position.province}">${province.name}</c:if>
        </c:forEach>
        <c:if test="${position.city != 0}">-
          <c:forEach items="${cities}" var="city">
            <c:if test="${city.id == position.city}">${city.name}</c:if>
          </c:forEach>
        </c:if>
      </td>
      <td><strong>发布日期</strong></td>
      <td width="10%"><fmt:formatDate value="${position.publishDate}" pattern="yyyy-MM-dd" /></td>
      <td width="8%"><strong>刷新日期</strong></td>
      <td width="10%"><fmt:formatDate value="${position.refreshDate}" pattern="yyyy-MM-dd" /></td>
      <td width="8%"><strong>结束日期</strong></td>
      <td width="10%"><fmt:formatDate value="${position.closeDate}" pattern="yyyy-MM-dd" /></td>
    </tr>
  </table>
  </c:forEach>

  <tags:pagination page="${positions}" paginationSize="5"/>

  <div><a class="btn" href="${ctx}/hr/position/create">创建职位</a></div>
</body>
</html>
